//字符串转数字
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int my_atoi(char *s)
{
    int result = 0;
    int flag = 1;
    if(*s == '-')
    {
        flag = -1;
        s++;
    }
    while(*s)
    {
        if(*s > '0' && *s < '9')   
        {
            result = result *10 + (*s - '0');
        }
        s++;
    }
    return result * flag;
}

int main(int argc, char * argv[])
{
    char src[1024];

    printf("Please input src:\n");
    scanf("%s",src);

    //int result = str2int(src);
    int result = my_atoi(src);

    printf("result = %d\n",result);

    return 0;
}